﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="menetlusinfo_v3_dokument", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(MenetlusinfoV3Dokument))]
    public class MenetlusinfoV3DokumentSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IMenetlusinfoV3Dokument clazz;
        
        public MenetlusinfoV3DokumentSerializer(IMenetlusinfoV3Dokument clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("paevikukande_id");
            if (clazz.PaevikukandeId!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PaevikukandeId))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PaevikukandeId");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("paevikukande_id_vana");
            if (clazz.PaevikukandeIdVana!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PaevikukandeIdVana))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PaevikukandeIdVana");
            }
            Writer.WriteEndElement();
            if (clazz.SeotudPaevikukandeId!=null) {
                Writer.WriteStartElement("seotud_paevikukande_id");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.SeotudPaevikukandeId))).ToString());
                Writer.WriteEndElement();
            }
            Writer.WriteStartElement("esit_kp");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.EsitKp))).ToString());
            Writer.WriteEndElement();
            if (clazz.DokLiik!=null) {
                Writer.WriteStartElement("dok_liik");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.DokLiik))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.DokOlek!=null) {
                Writer.WriteStartElement("dok_olek");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.DokOlek))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.NotarId!=null) {
                Writer.WriteStartElement("notar_id");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.NotarId))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.AastaNr!=null) {
                Writer.WriteStartElement("aasta_nr");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.AastaNr))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Notarnr!=null) {
                Writer.WriteStartElement("notarnr");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "int");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInt(((int)(clazz.Notarnr))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.EttevotjaRegKood!=null) {
                Writer.WriteStartElement("ettevotja_reg_kood");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.EttevotjaRegKood))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.EttevotjaNimi!=null) {
                Writer.WriteStartElement("ettevotja_nimi");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.EttevotjaNimi))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="paevikukande_id") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>menetlusinfo_v3_dokument>paevikukande_id");
                }
                clazz.PaevikukandeId = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("paevikukande_id")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>menetlusinfo_v3_dokument>paevikukande_id", Reader.LocalName);
            }
            if (Reader.LocalName=="paevikukande_id_vana") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>menetlusinfo_v3_dokument>paevikukande_id_vana");
                }
                clazz.PaevikukandeIdVana = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("paevikukande_id_vana")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>menetlusinfo_v3_dokument>paevikukande_id_vana", Reader.LocalName);
            }
            if (Reader.LocalName=="seotud_paevikukande_id") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.SeotudPaevikukandeId = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("seotud_paevikukande_id")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="esit_kp") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>menetlusinfo_v3_dokument>esit_kp");
                }
                clazz.EsitKp = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("esit_kp")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>menetlusinfo_v3_dokument>esit_kp", Reader.LocalName);
            }
            if (Reader.LocalName=="dok_liik") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.DokLiik = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("dok_liik")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="dok_olek") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.DokOlek = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("dok_olek")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="notar_id") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.NotarId = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("notar_id")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="aasta_nr") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.AastaNr = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("aasta_nr")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="notarnr") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Notarnr = new global::Xtee.Core.Schema.XsdInt(Reader.ReadElementString("notarnr")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="ettevotja_reg_kood") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.EttevotjaRegKood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("ettevotja_reg_kood")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="ettevotja_nimi") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.EttevotjaNimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("ettevotja_nimi")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
        }
    }
}
